// Includes
#include "geometric_image_filter/interval.h"

// -----------------
Interval::Interval()
// -----------------
{

}

// ----------------------------------------
Interval::Interval(double low, double high) :
        low(low), high(high)
// ----------------------------------------
{

}

// ------------------
Interval::~Interval()
// ------------------
{

}

// --------------------------------
double Interval::getLowPoint() const
// --------------------------------
{
        return this->low;
}

// ---------------------------------
double Interval::getHighPoint() const
// ---------------------------------
{
        return this->high;
}

// ------------------------------------------------
Interval Interval::intersect(Interval& other) const
// ------------------------------------------------
{
        double low = max(this->low, other.low);
        double high = min(this->high, other.high);

        return Interval(low, high);
}

// ------------------------------------------------
Interval* Interval::intersect(Interval* other) const
// ------------------------------------------------
{
        double low = max(this->low, other->low);
        double high = min(this->high, other->high);

        return new Interval(low, high);
}

// ---------------------------
bool Interval::isEmpty() const
// ---------------------------
{
        return this->high < this->low;
}

// -------------------------
void Interval::print() const
// -------------------------
{
        cout << "(" << this->low << ", " << this->high << ")" << endl;
}

// -----------------------------------
bool Interval::contains(double d) const
// -----------------------------------
{
        return (d >= this->low && d <= this->high);
}
